package com.tintuc24h.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tintuc24h.com.R;
import com.tintuc24h.models.RssItem;

public class NewAdapter extends ArrayAdapter<RssItem>{

	
	private Context context;
	private List<RssItem> items;
	private int ivicon;
	public NewAdapter(Context context, int ivicon,
			List<RssItem> items) {
		super(context, ivicon, items);
		this.context=context;
		this.ivicon=ivicon;
		this.items=items;
		
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View viewrow=inflater.inflate(R.layout.itemlist, parent, false);
		ImageView iv=(ImageView) viewrow.findViewById(R.id.ivicon);
		TextView tvtintuc=(TextView)viewrow.findViewById(R.id.tvtintuc);
		TextView tvdate=(TextView)viewrow.findViewById(R.id.tvdate);
		iv.setImageResource(ivicon);
		tvtintuc.setText(items.get(position).getTitle());
		tvdate.setText(items.get(position).getDate());
		
		return viewrow;
	}

}
